package com.pzhu.dao;

import com.pzhu.domain.Brand;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BrandDao {
    @Select("select * from tb_brand")
    @ResultMap("brandMap")
    List<Brand> selectAll();

    /**
     * 添加一条记录
     *
     * @param brand
     */

    @Insert("insert into tb_brand (brand_name, company_name, ordered, description, status) " +
            "values (#{brandName},#{companyName},#{ordered},#{description},#{status})")
    void add(Brand brand);

    /**
     * 删除一条记录
     *
     * @param brand
     */
    @Update("update tb_brand set brand_name=#{brandName},company_name=#{companyName}," +
            "ordered=#{ordered},description=#{description},status=#{status} where id=#{id}")
    void update(Brand brand);

    /**
     * 删除一条记录
     */
    @Delete("delete from tb_brand where id=#{id}")
    void delete(int id);

    /**
     * 批量删除记录
     */

    void deleteByIds(@Param("ids") int[] ids);

    /**
     * 分页查询
     *
     * @param begin
     * @param size
     * @return
     */
    @Select("select * from tb_brand limit #{begin}, #{size}")
    @ResultMap("brandMap")
    List<Brand> selectByPage(@Param("begin") int begin, @Param("size") int size);

    /**
     * 查询总记录数
     *
     * @return
     */
    @Select("select count(*) from tb_brand")
    int selectTotalCount();

    /**
     * 根据条件查询总记录数
     *
     * @return
     */

    int selectTotalCountByCondition(Brand brand);

    /**
     * 分页条件查询
     * @param begin
     * @param size
     * @return
     */

    List<Brand> selectByPageAndCondition(@Param("begin") int begin, @Param("size")int size, @Param("brand")Brand brand);

}

